package org.everyday;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @version v1.0.0
 * 创建时间：2022/8/4 09:11
 */
public class L1403 {
    public List<Integer> minSubsequence(int[] nums) {
        ArrayList<Integer> res = new ArrayList<>();
        Arrays.sort(nums);
        for (int i = 0; i < nums.length/2; i++) {
            int temp = nums[i];
            nums[i] = nums[nums.length-1-i];
            nums[nums.length-1-i] = temp;
        }
        int right = Arrays.stream(nums).sum();
        int left = 0;
        int index = 0;
        while(left<=right){
            int cur = nums[index];
            res.add(cur);
            left+=cur;
            right-=cur;
            index++;
        }
        return res;
    }

    public static void main(String[] args) {
        new L1403().minSubsequence(new int[]{4,3,10,9,8});

    }
}
